package HuaWeiOd.online;

import java.util.*;
import java.util.stream.Collectors;

public class    Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int[] arr = Arrays.stream(sc.nextLine().split(" ")).mapToInt(Integer::parseInt).toArray();
        // 统计牌出现的次数
        Map<Integer, Integer> map = new TreeMap<>();
        for (int num : arr) {
            Integer count = map.getOrDefault(num, 0);
            map.put(num, count + 1);
        }
        Map<Integer, Map<Integer, List<Integer>>> map1 = new TreeMap<>((o1, o2) -> o2-o1);

        for (Integer key : map.keySet()) {
            Integer count = map.get(key);
            int[] narr = new int[count];
            Arrays.fill(narr, key);


            Map<Integer, List<Integer>> map2 = map1.getOrDefault(count, new TreeMap<>((o1, o2) -> o2 - o1));

            List<Integer> collect = Arrays.stream(narr).boxed().collect(Collectors.toList());
            map2.put(key, collect);

            map1.put(count, map2);
        }

        for (Integer key : map1.keySet()) {
            Map<Integer, List<Integer>> integerListMap = map1.get(key);
            if (key >= 4 || key == 2 || key == 1) {
                for (List<Integer> value : integerListMap.values()) {
                    for (Integer integer : value) {
                        System.out.print(integer + " ");
                    }
                }
            } else if (key == 3) {

                for (List<Integer> value : integerListMap.values()) {
                    for (Integer integer : value) {
                        System.out.print(integer + " ");
                    }
                    // 取出所有对子
                    Map<Integer, List<Integer>> integerListMap1 = map1.get(2);
                    if (integerListMap1 != null && integerListMap1.keySet().size() != 0) {
                        Iterator<Integer> iterator = integerListMap1.keySet().iterator();
                        while(iterator.hasNext()) {
                            Integer next = iterator.next();
                            List<Integer> integers = integerListMap1.get(next);
                            for (Integer integer : integers) {
                                System.out.print(integer + " ");
                            }
                            integerListMap1.remove(next);
                            break;
                        }
                    }
                }
            }
        }



        System.out.println();

    }
}